const merge = require("webpack-merge");
const path = require("path");
const fs = require('fs');
const random = require('string-random');
const dir = require("./dir");

const pathToName = require(path.join(dir.frameworkCommonDir, 'driver')).pathToName;
const resolve = require("./driver").resolve;
const webpackPromise = require("./driver").webpackPromise;


const common = require("./webpack.common.js");


// 构建前清理
const CleanWebpackPlugin = require("clean-webpack-plugin");
// HTML 模板
const HtmlWebpackPlugin = require("html-webpack-plugin");
// 纯静态资源复制
const CopyWebpackPlugin = require("copy-webpack-plugin");

module.exports = async (app) => {
    let runner = null;
    let config = require(path.join(dir.rootDir, app || '', 'config.js'));
    for (let key in config.plugs) {
        let url = config.plugs[key].url;
        runner = require('./webpack.plug');
        await runner(url);
    }
    runner = require('./webpack.app.config');
    await runner(app);
    runner = require('./webpack.app.build');
    await runner(app);
};
